<?php

/**
 * This is the model class for table "luastanamproduksijagung".
 *
 * The followings are the available columns in table 'luastanamproduksijagung':
 * @property integer $ltpj_id
 * @property integer $ltpj_kec
 * @property integer $ltpj_tanam
 * @property integer $ltpj_panen
 * @property integer $ltpj_produksi
 * @property double $ltpj_rata
 * @property integer $ltpj_tahun
 *
 * The followings are the available model relations:
 * @property Kecamatan $ltpjKec
 */
class Luastanamproduksijagung extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Luastanamproduksijagung the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'luastanamproduksijagung';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('ltpj_kec, ltpj_tanam, ltpj_panen, ltpj_produksi, ltpj_tahun', 'numerical', 'integerOnly'=>true),
			array('ltpj_rata', 'numerical'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('ltpj_id, ltpj_kec, ltpj_tanam, ltpj_panen, ltpj_produksi, ltpj_rata, ltpj_tahun', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'ltpjKec' => array(self::BELONGS_TO, 'Kecamatan', 'ltpj_kec'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'ltpj_id' => 'Ltpj',
			'ltpj_kec' => 'Ltpj Kec',
			'ltpj_tanam' => 'Luas Tanam(Ha)',
			'ltpj_panen' => 'Luas Panen(Ha)',
			'ltpj_produksi' => 'Produksi(Ton)',
			'ltpj_rata' => 'Rata-Rata',
			'ltpj_tahun' => 'Tahun',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('ltpj_id',$this->ltpj_id);
		$criteria->compare('ltpj_kec',$this->ltpj_kec);
		$criteria->compare('ltpj_tanam',$this->ltpj_tanam);
		$criteria->compare('ltpj_panen',$this->ltpj_panen);
		$criteria->compare('ltpj_produksi',$this->ltpj_produksi);
		$criteria->compare('ltpj_rata',$this->ltpj_rata);
		$criteria->compare('ltpj_tahun',$this->ltpj_tahun);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}